<template>
  <view class="index">
    <div class="nav" style="height: 60rpx"></div>
    <div class="img">
      <image src="../../static/diImage/登录.svg" mode=""></image>
    </div>

    <div class="one">
      <up-input
        placeholder="请输入账号"
        prefixIcon="account"
        prefixIconStyle="font-size: 22px;color: #909399"
        v-model="name"
      ></up-input>
      <div class="dd" style="height: 40rpx"></div>
      <up-input
        placeholder="请输入密码"
        prefixIcon="lock"
        prefixIconStyle="font-size: 22px;color: #909399"
        password
        v-model="password"
      ></up-input>
      <div class="dd" style="height: 100rpx"></div>
      <up-button type="primary" @click="add">登录</up-button>
    </div>
    <div class="p">忘记登录密码</div>
    <!-- <u-notify ref="uNotify" message="Hi uview-plus"></u-notify> -->
    <div class="list" v-show="show">
      <div class="pp">{{ title }}</div>
    </div>
 </view>
</template>

<script>
export default {
  data() {
    return {
      name: "",
      password: "",
      list: [],
      title:'',
      show:false
    };
  },
  onLoad() {},
  methods: {
    add() {
      // uni.reLaunch({
      //   url: "/pages/shou/shou",
      // });
      for (let i = 0; i < this.list.length; i++) {
        if (
          this.list[i].username == this.name &&
          this.list[i].password == this.password
        ) {
          this.show=true
          this.title='登录成功'
          setTimeout(()=>{
            this.show=false
          },1500)
          uni.reLaunch({ url: "/pages/shou/shou" });
        }
        if (this.name == "" || this.password == "") {
          
          this.show=true
          this.title='账号或密码不能为空'
          setTimeout(()=>{
            this.show=false
          },1500)
        }
		else{
			
          this.show=true
          this.title='账号或密码错误'
          setTimeout(()=>{
            this.show=false
          },1500)
		}
      }
    },
  },
  created() {
    uni.request({
      url: "http://127.0.0.1:3000/login/getAll", //接口地址
      method: "POST",
      success: (res) => {
        this.list = res.data.data;
        console.log(this.list, "账号密码");
      },
    });
  },
};
</script>

<style lang="scss">
.list{
  width: 80%;
  height: 100rpx;
  background: rgba($color: #000000, $alpha: 0.6);
  border-radius: 20rpx;
  position: fixed;
  top: 49%;
  left: 9%;
  .pp{
    width: 100%;
    height: 100%;
    text-align: center;
    line-height: 100rpx;
    color: white;
  }
}
.one {
  padding: 20rpx;
  width: 100%;
}
.img {
  width: 100%;
  height: 600rpx;
  padding: 100rpx;
}
image {
  width: 100%;
  height: 100%;
}
.p {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #3c9cff;
  margin-top: 60rpx;
}
</style>
